#ifndef _EDIT_NOTEBOOK_H_
#define _EDIT_NOTEBOOK_H_

#include "wx/notebook.h"
#include "wx/aui/auibook.h"
#include "Control_Pref.h"
#include "../Editor/edit.h"
//#include "../BLL/bll.h"

WX_DECLARE_OBJARRAY(Edit*,EditArray);
WX_DECLARE_OBJARRAY(MYSQL*,MySQLArray);
WX_DECLARE_OBJARRAY(int,SelectedIndexArray);

class EditNotebook : public wxAuiNotebook{

public:
	void AddDbList(wxString list,bool initial=true,int index=0);
	void AddEdit(MYSQL* mysql,wxString name);
	EditNotebook(wxWindow* parent, wxWindowID id = wxID_ANY, 
		const wxPoint& pos = wxDefaultPosition, 
		const wxSize& size = wxDefaultSize,
		const wxString& name = wxEmptyString);
	~EditNotebook();
	Edit* GetEditByIndex(int index){ return editArray[index]; }
//	void AddEdit(Edit* edit,wxString name);
	int GetEditCount () { return editArray.GetCount(); }
	MYSQL* GetCurrentMySQL() { return mysqlArray[GetSelection()]; }
	wxString GetCurrentText() { return ((Edit*)GetPage(GetSelection()))->GetText() ; }
	wxString GetCurrentLineText() { return ((Edit*)GetPage(GetSelection()))->GetCurLine(); }
	wxString GetCurrentSelectedText() { return ((Edit*)GetPage(GetSelection()))->GetSelectedText(); }
	Edit* GetCurrentEdit() { return ((Edit*)GetPage(GetSelection())); }
	void SetCurrentEditFocus() { GetCurrentEdit()->SetFocus(); }
	void ClosePageByIndex(int index);
	EditArray GetEditArray() { return editArray; }
	MYSQL* GetMySQLByIndex(int index){ return mysqlArray[index]; }
	wxString GetDbListByIndex( unsigned int index ) { if ( index >= dbList.GetCount() ) return wxEmptyString; return dbList[index]; }
	wxArrayString GetDbLists() { return dbList; }
	void SetSelectedByIndex(int index,int selected){ this->selected[index] = selected; }
	int GetSelectedByIndex(int index){ return selected[index]; }
//	void OnPageChanged(wxAuiNotebookEvent& event);
private:
	EditArray editArray;
	MySQLArray mysqlArray;
    DECLARE_EVENT_TABLE()
	wxArrayString dbList;
	SelectedIndexArray selected;

};

#endif